<template>
	<view class="my-watch">
		<view class="my-watch-userlist">
			<view class="none" v-if="blackList.length == 0">还没有添加任何人</view>
			<view class="my-watch-userlist-item" v-for="(item,index) in blackList" :key="index">
				<view class="left">
					<view class="item-avatar">
						<image :src="item.avatar ? item.avatar : defimg"></image>
					</view>
					<view class="item-user">
						<view class="name">{{item.nicheng}}</view>
						<view class="state">{{item.autograph}}</view>
					</view>
				</view>
				<view class="item-state_cancle" @tap="remove(item.user_id)">移除</view>
			</view>
			<uni-load-more v-if="blackList.length >= 12" :status="status" :content-text="contentText" />
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default{
		components: {
			uniLoadMore
		},
		data() {
			return {
				form_id: '',
				blackList: [],
				page: 1,
				reload: true,
				status: 'more',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多',
					contentnot: "没数据"
				},
				defimg: this.defimg
			}
		},
		onPullDownRefresh() {
			this.reload = true;
			this.page = 1;
			this.getBlack();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.status = 'loading';
			this.page = this.page + 1;
			var _this = this;
			setTimeout(function() {
				_this.getBlack();
			}, 500);
		},
		onLoad(e) {
			this.form_id = e.user_id;
			this.getBlack();
		},
		methods: {
			/* 获取黑名单列表 */
			getBlack() {
				var data = {
					page: this.page,
					pagesize: 15
				}
				this.$zapi.apiPost('user/video.User/UserBlackList',data).then(res=>{
					if(res.data.code == 200) {
						var list = res.data.data.data;
						this.blackList = this.reload ? list : this.blackList.concat(list);
						this.reload = false;
						this.status = 'more';
					} else { 
						if (this.reload) {
							this.blackList = [];
						} else {
							this.status = 'noMore';
						}
					}
				})
			},
			/* 移出黑名单 */
			remove(user_id) {
				this.$zapi.apiPost('user/video.User/BlackDel',{form_id:user_id}).then(res=>{
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
					this.page = 1;
					this.reload = true;
					this.getBlack();
				})
			}
		}
	}
</script>

<style lang="scss">
	.my-watch {
		width: 690upx;
		margin: 0 auto;
		// 我的粉丝/推荐用户列表
		.my-watch-userlist {
			.none {
				color: #999999;
				text-align: center;
				margin: 100upx 0;
			}
			.my-watch-userlist-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin: 30upx 0;
				.left{
					display: flex;
					justify-content: flex-start;
					align-items: center;
				}
				.item-avatar {
					margin-right: 10upx;
					image {
						width: 72upx;
						height: 72upx;
						border-radius: 50%;
					}
				}
				.item-user{
					.name{
						color: #333333;
						font-size: 32upx;
						line-height: 1;
					}
					.state {
						color: #999999;
						font-size: 26upx;
						display: flex;
						justify-content: flex-start;
						align-items: center;
					}
				}
				.item-state{
					color: #FF9900;
					font-size: 26upx;
				}
				.item-state_cancle{
					color: #999999;
					font-size: 26upx;
					white-space: nowrap;
				}
			}
		}
	}
</style>
